//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "KrugerCubic.h"
using namespace Cephei::QL::Math::Interpolations;
#include <gen/QL/Math/Interpolations/CubicInterpolation.h>
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::Interpolations::CKrugerCubic::CKrugerCubic (boost::shared_ptr<QuantLib::KrugerCubic>& childNative, Object^ owner) : CCubicInterpolation(CKrugerCubic::typeid)
{
#ifdef HANDLE
	_phKrugerCubic = NULL;
#endif
	_ppKrugerCubic = &childNative;
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppKrugerCubic));
}
Cephei::QL::Math::Interpolations::CKrugerCubic::CKrugerCubic (QuantLib::KrugerCubic& childNative, Object^ owner) : CCubicInterpolation(CKrugerCubic::typeid)
{
#ifdef HANDLE
	_phKrugerCubic = NULL;
#endif
	_ppKrugerCubic = new boost::shared_ptr<QuantLib::KrugerCubic> (&childNative);
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppKrugerCubic));
    _KrugerCubicOwner = owner;
    _CubicInterpolationOwner = owner;
}

Cephei::QL::Math::Interpolations::CKrugerCubic::CKrugerCubic (CKrugerCubic^ copy) : CCubicInterpolation(CKrugerCubic::typeid)
{
#ifdef HANDLE
	_phKrugerCubic = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppKrugerCubic = new boost::shared_ptr<QuantLib::KrugerCubic> (copy->GetShared());
        _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppKrugerCubic));
    }
}
Cephei::QL::Math::Interpolations::CKrugerCubic::CKrugerCubic (System::Type^ t) : CCubicInterpolation(CKrugerCubic::typeid)
{
#ifdef HANDLE
	_phKrugerCubic = NULL;
#endif
	if (!t->IsSubclassOf(CKrugerCubic::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::Interpolations::CKrugerCubic::CKrugerCubic (QuantLib::Handle<QuantLib::KrugerCubic>& childNative, Object^ owner)  : CCubicInterpolation(CKrugerCubic::typeid)
{
	_phKrugerCubic = &childNative;
	_ppKrugerCubic = &static_cast<boost::shared_ptr<QuantLib::KrugerCubic>>(childNative.currentLink());
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppKrugerCubic));
    _KrugerCubicOwner = owner;
}
Cephei::QL::Math::Interpolations::CKrugerCubic::CKrugerCubic (QuantLib::Handle<QuantLib::KrugerCubic> childNative)  : CCubicInterpolation(CKrugerCubic::typeid)
{
	_phKrugerCubic = &childNative;
	_ppKrugerCubic = &static_cast<boost::shared_ptr<QuantLib::KrugerCubic>>(childNative.currentLink());
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppKrugerCubic));
}
#endif
#ifdef STRUCT
Cephei::QL::Math::Interpolations::CKrugerCubic::CKrugerCubic (QuantLib::KrugerCubic childNative)  : CCubicInterpolation(CKrugerCubic::typeid)
{
#ifdef HANDLE
	_phKrugerCubic = NULL;
#endif
	_ppKrugerCubic = new boost::shared_ptr<QuantLib::KrugerCubic> (new QuantLib::KrugerCubic (childNative));
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppKrugerCubic));
}
#endif

Cephei::QL::Math::Interpolations::CKrugerCubic::~CKrugerCubic ()
{
    if (_ppKrugerCubic != NULL)
    {
	    delete _ppKrugerCubic;
        _ppKrugerCubic = NULL;
    }
}
Cephei::QL::Math::Interpolations::CKrugerCubic::!CKrugerCubic ()
{
    if (_ppKrugerCubic != NULL)
    {
	    delete _ppKrugerCubic;
    }
}
QuantLib::KrugerCubic& Cephei::QL::Math::Interpolations::CKrugerCubic::GetReference ()
{
    if (_ppKrugerCubic == NULL) throw gcnew NativeNullException ();
	return **_ppKrugerCubic;
}
boost::shared_ptr<QuantLib::KrugerCubic>& Cephei::QL::Math::Interpolations::CKrugerCubic::GetShared ()
{
    if (_ppKrugerCubic == NULL) throw gcnew NativeNullException ();
	return *_ppKrugerCubic;
}
QuantLib::KrugerCubic* Cephei::QL::Math::Interpolations::CKrugerCubic::GetPointer ()
{
    if (_ppKrugerCubic == NULL) throw gcnew NativeNullException ();
	return &**_ppKrugerCubic;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::KrugerCubic>& Cephei::QL::Math::Interpolations::CKrugerCubic::GetHandle ()
{
	if (_phKrugerCubic == NULL)
	{
		_phKrugerCubic = new Handle<QuantLib::KrugerCubic> (*_ppKrugerCubic);
	}
	return *_phKrugerCubic;
}
#endif
bool Cephei::QL::Math::Interpolations::CKrugerCubic::HasNative () 
{
	return (_ppKrugerCubic != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

